import java.util.ArrayList;

public class Main {
	/**
	 * Store all prime numbers <10000 in a collection class that is to be output
	 * to the user.
	 */
	public Main() {
		ArrayList<Integer> primes = new ArrayList<Integer>();
		// Add the first prime number to use the following method.
		// Divide number by all previous primes, if it works for any previous
		// primes, the number is not a prime number.
		primes.add(2);
		int pos = 0;
		for (int i = 3; i < 10000; i++) {
			primes.add(i); //Assume the number is a prime.
			pos++;
			for (Integer current : primes) {
				int temp = primes.get(pos);
				if (temp % current == 0 && temp != current){
					primes.remove(pos);
					--pos;
					break;
				}
			}
			
		}
		System.out.println(primes);
	}

	public static void main(String[] args) {
		new Main();
	}
}
